// $Id$
// vim:ft=javascript

ARG_WITH("sqlite", "SQLite support", "no");

if (PHP_SQLITE != "no") {
	copy_and_subst(configure_module_dirname + "\\libsqlite\\src\\sqlite.h.in",
		configure_module_dirname + "\\libsqlite\\src\\sqlite.h", new Array(
			"--VERS--", file_get_contents(configure_module_dirname + "\\libsqlite\\VERSION").replace(new RegExp("[\r\n]+", "g"), ""),
			"--ENCODING--", "ISO8859"
		));
	
	FSO.CopyFile(configure_module_dirname + "\\libsqlite\\src\\sqlite_config.w32.h",
	   	configure_module_dirname + "\\libsqlite\\src\\config.h");

	if (FSO.FileExists(configure_module_dirname + "\\..\\pdo\\php_pdo_driver.h")) {
		PHP_SQLITE2_PDO_CFLAGS = " /DPHP_SQLITE2_HAVE_PDO=1 /I " + configure_module_dirname + "\\..";
		ADD_EXTENSION_DEP('sqlite', 'pdo')
	} else {
		PHP_SQLITE2_PDO_CFLAGS = "";
	}
	
	EXTENSION("sqlite", "sqlite.c sess_sqlite.c pdo_sqlite2.c", null,
		"/D PHP_SQLITE_EXPORTS /I " + configure_module_dirname + "/libsqlite/src" +
		PHP_SQLITE2_PDO_CFLAGS);
		
	
	ADD_SOURCES(configure_module_dirname + "/libsqlite/src", "opcodes.c parse.c encode.c \
		auth.c btree.c build.c delete.c expr.c func.c hash.c insert.c \
		main.c os.c pager.c printf.c random.c select.c table.c tokenize.c \
		update.c util.c vdbe.c attach.c btree_rb.c pragma.c vacuum.c \
		copy.c where.c trigger.c vdbeaux.c date.c", "sqlite");

	AC_DEFINE("HAVE_SQLITE", 1, "SQLite support");
	if (!PHP_SQLITE_SHARED) {
		ADD_DEF_FILE(configure_module_dirname + "\\php_sqlite.def");
	}
	ADD_EXTENSION_DEP('sqlite', 'spl')
}
